package com.ltkj.ticket.controller;

import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.ticket.domain.TicScenic;
import com.ltkj.ticket.service.ITicScenicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 景区门票基础Controller
 * 
 * @author ruoyi
 * @date 2023-08-31
 */
@Api(tags = "景区门票基础")
@RestController
@RequestMapping("/scenic")
public class TicScenicController extends BaseController
{
    @Autowired
    private ITicScenicService ticScenicService;

    /**
     * 查询景区门票基础列表
     */
    @ApiOperation("查询景区门票基础列表")
    @RequiresPermissions("tictket:scenic:list")
    @GetMapping("/list")
    public TableDataInfo list(TicScenic ticScenic)
    {
        startPage();
        List<TicScenic> list = ticScenicService.selectTicScenicList(ticScenic);
        return getDataTable(list);
    }
    @ApiOperation("查询景区门票基础列表优惠券")
    @GetMapping("/listCoupontem")
    public AjaxResult listCoupontem(TicScenic ticScenic)
    {
        List<TicScenic> list = ticScenicService.selectTicScenicList(ticScenic);
        return success(list);
    }
    /**
     * 查询景区门票基础列表
     */
    @ApiOperation("查询景区其他信息列表")
    @RequiresPermissions("tictket:scenic:other")
    @GetMapping("/listTicOherBase")
    public AjaxResult listTicOherBase(String otherBaseType)
    {
        return ticScenicService.selectTicOtherBaseList(otherBaseType);
    }


    /**
     * 导出景区门票基础列表
     */
    @ApiOperation("导出景区门票基础列表")
    @RequiresPermissions("tictket:scenic:export")
    @Log(title = "景区门票基础", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicScenic ticScenic)
    {
        List<TicScenic> list = ticScenicService.selectTicScenicList(ticScenic);
        ExcelUtil<TicScenic> util = new ExcelUtil<TicScenic>(TicScenic.class);
        util.exportExcel(response, list, "景区门票基础数据");
    }

    /**
     * 获取景区门票基础详细信息
     */
    @ApiOperation("获取景区门票基础详细信息")
    @RequiresPermissions("tictket:scenic:query")
    @GetMapping(value = "/{scenicId}")
    public AjaxResult getInfo(@PathVariable("scenicId") Long scenicId)
    {
        return success(ticScenicService.selectTicScenicByScenicId(scenicId));
    }

    /**
     * 新增景区门票基础
     */
    @ApiOperation("新增景区门票基础")
    @RequiresPermissions("tictket:scenic:add")
    @Log(title = "景区门票基础", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicScenic ticScenic)
    {
        return toAjax(ticScenicService.insertTicScenic(ticScenic));
    }

    /**
     * 修改景区门票基础
     */
    @ApiOperation("修改景区门票基础")
    @RequiresPermissions("tictket:scenic:edit")
    @Log(title = "景区门票基础", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TicScenic ticScenic)
    {
        return toAjax(ticScenicService.updateTicScenic(ticScenic));
    }

    /**
     * 删除景区门票基础
     */
    @ApiOperation("删除景区门票基础")
    @RequiresPermissions("tictket:scenic:remove")
    @Log(title = "景区门票基础", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scenicIds}")
    public AjaxResult remove(@PathVariable Long[] scenicIds)
    {
        return toAjax(ticScenicService.deleteTicScenicByScenicIds(scenicIds));
    }

    /**
     * 下架景区门票基础
     */
    @ApiOperation("景区门票下架")
    @RequiresPermissions("ticket:scenic:offshelf")
    @Log(title = "景区门票下架", businessType = BusinessType.OFFSHELF)
    @GetMapping("/offshelf/{scenicId}")
    public AjaxResult offshelf(@PathVariable("scenicId") Long scenicId)
    {
        return toAjax(ticScenicService.offshelf(scenicId));
    }

    /**
     * 下架景区门票基础
     */
    @ApiOperation("景区门票上架")
    @RequiresPermissions("ticket:scenic:onshelf")
    @Log(title = "景区门票上架", businessType = BusinessType.ONSHELF)
    @GetMapping("/onshelf/{scenicId}")
    public AjaxResult onshelf(@PathVariable("scenicId") Long scenicId)
    {
        return toAjax(ticScenicService.onshelf(scenicId));
    }

    /**
     * 查询景区门票基础列表
     */
    @ApiOperation("查询景区门票基础下拉")
    @RequiresPermissions("tictket:scenic:select")
    @GetMapping("/select")
    public AjaxResult list()
    {
        TicScenic ticScenic = new TicScenic();
        ticScenic.setIsDel("0");
        return AjaxResult.success(ticScenicService.selectTicScenicList(ticScenic));
    }
}

